{% set pypi_name = 'os-faults' %}
{% set upstream_version = upstream_version('0.2.7') %}
{% set rpm_release = '1' %}

Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        OpenStack fault-injection library
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://os-faults.readthedocs.io
Source0:        https://files.pythonhosted.org/packages/source/o/os-faults/os_faults-%{version}.tar.gz
BuildRequires:  {{ py3('ansible', ('>=', '2.2')) }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('PyYAML') }}
BuildRequires:  {{ py3('appdirs') }}
BuildRequires:  {{ py3('click') }}
BuildRequires:  {{ py3('ddt') }}
BuildRequires:  {{ py3('iso8601') }}
BuildRequires:  {{ py3('jsonschema') }}
BuildRequires:  {{ py3('libvirt-python') }}
BuildRequires:  {{ py3('mock') }}
BuildRequires:  {{ py3('oslo.concurrency') }}
BuildRequires:  {{ py3('oslo.i18n') }}
BuildRequires:  {{ py3('oslo.serialization') }}
BuildRequires:  {{ py3('oslo.utils') }}
BuildRequires:  {{ py3('oslotest') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('pyghmi') }}
BuildRequires:  {{ py3('pytest') }}
BuildRequires:  {{ py3('python-subunit') }}
BuildRequires:  {{ py3('six') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('testscenarios') }}
BuildRequires:  {{ py3('testtools') }}
Requires:       {{ py3('ansible', ('>=', '2.2')) }}
Requires:       {{ py3('PyYAML') }}
Requires:       {{ py3('appdirs') }}
Requires:       {{ py3('click') }}
Requires:       {{ py3('iso8601') }}
Requires:       {{ py3('jsonschema') }}
Requires:       {{ py3('oslo.concurrency') }}
Requires:       {{ py3('oslo.i18n') }}
Requires:       {{ py3('oslo.serialization') }}
Requires:       {{ py3('oslo.utils') }}
Requires:       {{ py3('pbr') }}
Requires:       {{ py3('pyghmi') }}
Requires:       {{ py3('six') }}
BuildArch:      noarch
%if ! 0%{?rhel}
Recommends:     {{ py3('libvirt-python') }}
%endif

%description
The library does destructive actions inside an OpenStack cloud. It provides
an abstraction layer over different types of cloud deployments. The actions
are implemented as drivers (e.g. DevStack driver, Fuel driver, Libvirt driver,
IPMI driver).

%package doc
Summary:        Documentation for OpenStack faults Library
Group:          Documentation/HTML
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}
BuildRequires:  {{ py3('reno') }}
BuildRequires:  {{ py3('sphinx_rtd_theme') }}
%if ! 0%{?rdo}
# this package its dependency js-jquery is not available for RDO
BuildRequires:  {{ py3('sphinxcontrib-programoutput') }}
%endif

%description doc
The library does destructive actions inside an OpenStack cloud. It provides
an abstraction layer over different types of cloud deployments. The actions
are implemented as drivers (e.g. DevStack driver, Fuel driver, Libvirt driver,
IPMI driver).

This package contains the documentation.

%prep
%autosetup -p1 -n os_faults-%{version}
%py_req_cleanup
%if 0%{?rdo}
sed -i '/sphinxcontrib.programoutput/d' doc/source/conf.py
sed -i '/sphinx.ext.autosectionlabel/d' doc/source/conf.py
%endif

%build
%{py3_build}
PBR_VERSION={{ upstream_version }} PYTHONPATH=. %sphinx_build -b html doc/source doc/build/html
rm -rf doc/build/html/.{doctrees,buildinfo}

%install
%{py3_install}

%check
export PYTHONPATH=.
export PATH=$PATH:%{buildroot}%{_bindir}
python3 -m pytest -vvvv --durations=10 "os_faults/tests/unit"

%files
%doc README.rst ChangeLog
%license LICENSE
%{_bindir}/os-inject-fault
%{_bindir}/os-faults
%{python3_sitelib}/os_faults*

%files doc
%if ! 0%{?rdo}
%doc doc/build/html
%endif
%license LICENSE

%changelog
